package st.business.tepth.business.login;

import st.business.tepth.base.OnDataConvertListener;
import st.business.tepth.manager.UserBean;

/**
 * Author: shadow
 * Email:  1025431817@qq.com
 * Time:   2019-01-14 19:23
 */

public class LoginPresenter extends LoginContract.Presenter {
    private final LoginContract.View mView;
    private final LoginContract.Model mModel;

    public LoginPresenter(LoginContract.View view) {
        mView = view;
        mModel = new LoginModel();
    }

    @Override
    void login(String account, String password, int type) {
        addDisposable(mModel.login(account, password, type, new OnDataConvertListener<UserBean>() {
            @Override
            public void convert(UserBean userBean) {
                mView.succeed(userBean);
            }

            @Override
            public void error(int code, String msg) {
                mView.failed(code, msg);
            }
        }));
    }
}
